package com.seelyn.rhea.mvc.context;

import javax.servlet.http.HttpServletResponse;

/**
 * @author slacrey
 * @since 2016/1/23
 */
public interface Response {

    /**
     * 设置状态
     * @param statusCode 状态码
     */
    void status(int statusCode);

    /**
     * 设置内容类型
     *
     * @param contentType 内容类型
     */
    void type(String contentType);

    /**
     * Sets the body
     *
     * @param body the body
     */
    void body(String body);

    /**
     * returns the body
     *
     * @return the body
     */
    String body();

    /**
     * @return the raw response object handed in by Jetty
     */
    HttpServletResponse raw();

    /**
     * Trigger a browser redirect
     *
     * @param location Where to redirect
     */
    void redirect(String location);

    /**
     * Trigger a browser redirect with specific http 3XX status code.
     *
     * @param location       Where to redirect permanently
     * @param httpStatusCode the http status code
     */
    void redirect(String location, int httpStatusCode);

    /**
     * Adds/Sets a response header
     *
     * @param header the header
     * @param value  the value
     */
    void header(String header, String value);

    /**
     * Adds not persistent cookie to the response.
     * Can be invoked multiple times to insert more than one cookie.
     *
     * @param name  name of the cookie
     * @param value value of the cookie
     */
    void cookie(String name, String value);

    /**
     * Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
     *
     * @param name   name of the cookie
     * @param value  value of the cookie
     * @param maxAge max age of the cookie in seconds (negative for the not persistent cookie,
     *               zero - deletes the cookie)
     */
    void cookie(String name, String value, int maxAge);

    /**
     * Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
     *
     * @param name    name of the cookie
     * @param value   value of the cookie
     * @param maxAge  max age of the cookie in seconds (negative for the not persistent cookie, zero - deletes the cookie)
     * @param secured if true : cookie will be secured
     */
    void cookie(String name, String value, int maxAge, boolean secured);

    /**
     * Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
     *
     * @param name     name of the cookie
     * @param value    value of the cookie
     * @param maxAge   max age of the cookie in seconds (negative for the not persistent cookie, zero - deletes the cookie)
     * @param secured  if true : cookie will be secured
     * @param httpOnly if true: cookie will be marked as http only
     */
    void cookie(String name, String value, int maxAge, boolean secured, boolean httpOnly);

    /**
     * Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
     *
     * @param path    path of the cookie
     * @param name    name of the cookie
     * @param value   value of the cookie
     * @param maxAge  max age of the cookie in seconds (negative for the not persistent cookie, zero - deletes the cookie)
     * @param secured if true : cookie will be secured
     */
    void cookie(String path, String name, String value, int maxAge, boolean secured);

    /**
     * 添加cookie
     *
     * @param path     cookie的path
     * @param name     cookie的名字
     * @param value    cookie的值
     * @param maxAge   cookie最大的存活时间 秒
     * @param secured  如果为true则是安全的
     * @param httpOnly if true: cookie will be marked as http only
     */
    void cookie(String path, String name, String value, int maxAge, boolean secured, boolean httpOnly);

    /**
     * 删除cookie
     *
     * @param name cookie名字
     */
    void removeCookie(String name);

}
